using System;
using System.Data;
using System.Collections.Generic;
using ADOBase;

namespace eTMS.DAO{
	/********************************BEGIN KhoaBangDiemDAO****************************************/
	///<summary>
	/// <para>Author: Auto generated class by CSharp Code Generator v2.0</para>
	/// <para>Date:16/01/2012 25:11:54</para>
	/// <para>Class Name: KhoaBangDiemDAO</para>
	/// <para>Description: Class access to table KhoaBangDiem in database. Coder should'nt code here.</para>
	///</summary>

	
	public partial class KhoaBangDiemDAO : DAOBase<KhoaBangDiemEntity>{


		#region Select functions
		///<summary>
		/// <para>Author: Auto generated by CSharp Code Generator v2.0</para>
		/// <para>Date:16/01/2012 25:11:54</para>
		/// <para>Name: CreateSelectOneCommand</para>
		/// <para>Input: KhoaBangDiem_ID</para>
		/// <para>Output: IDbCommand</para>
		///</summary>
		protected IDbCommand CreateSelectOneCommand(int KhoaBangDiem_ID){
			string strSQL="SELECT  [KhoaBangDiem_ID],[LoaiDiem_ID],[MonHoc_ID],[LanThi],[User_ID],[KhoaDoiTuong_ID],[LoaiKhoa],[TrangThai],[NgayKhoa] FROM [KhoaBangDiem]  WHERE [KhoaBangDiem].[KhoaBangDiem_ID]=@KhoaBangDiem_ID";
			IDbCommand cmd=this.CreateCommand(strSQL);
			cmd.CommandType=CommandType.Text;
			this.CreateCommandParameter(cmd,"@KhoaBangDiem_ID",KhoaBangDiem_ID);



			return cmd;
		}
		///<summary>
		/// <para>Author: Auto generated by CSharp Code Generator v2.0</para>
		/// <para>Date:16/01/2012 25:11:54</para>
		/// <para>Name: SelectOne</para>
		/// <para>Input: KhoaBangDiem_ID</para>
		/// <para>Output: KhoaBangDiemEntity</para>
		///</summary>
		public KhoaBangDiemEntity SelectOne(int KhoaBangDiem_ID){
			IDbCommand cmd=this.CreateSelectOneCommand(KhoaBangDiem_ID);
			return this.Select(cmd);
		}
		///<summary>
		/// <para>Author: Auto generated by CSharp Code Generator v2.0</para>
		/// <para>Date:16/01/2012 25:11:54</para>
		/// <para>Name: CreateSelectAllCommand</para>
		/// <para>Input: </para>
		/// <para>Output: IDbCommand</para>
		///</summary>
		protected IDbCommand CreateSelectAllCommand(){
			string strSQL="SELECT  [KhoaBangDiem_ID],[LoaiDiem_ID],[MonHoc_ID],[LanThi],[User_ID],[KhoaDoiTuong_ID],[LoaiKhoa],[TrangThai],[NgayKhoa] FROM [KhoaBangDiem] ";
			IDbCommand cmd=this.CreateCommand(strSQL);
			cmd.CommandType=CommandType.Text;
			return cmd;
		}
		///<summary>
		/// <para>Author: Auto generated by CSharp Code Generator v2.0</para>
		/// <para>Date:16/01/2012 25:11:54</para>
		/// <para>Name: CreateSelectAllByKeyCommand</para>
		/// <para>Input: ColumnName,ColumnValue</para>
		/// <para>Output: IDbCommand</para>
		///</summary>
		protected IDbCommand CreateSelectAllByKeyCommand(string ColumnName,object Value){
			string strSQL="SELECT  [KhoaBangDiem_ID],[LoaiDiem_ID],[MonHoc_ID],[LanThi],[User_ID],[KhoaDoiTuong_ID],[LoaiKhoa],[TrangThai],[NgayKhoa] FROM [KhoaBangDiem]  WHERE [KhoaBangDiem].["+ColumnName+"]=@ColumnName";
			IDbCommand cmd=this.CreateCommand(strSQL);
			cmd.CommandType=CommandType.Text;
			this.CreateCommandParameter(cmd,"@ColumnName",Value);



			return cmd;
		}
		///<summary>
		/// <para>Author: Auto generated by CSharp Code Generator v2.0</para>
		/// <para>Date:16/01/2012 25:11:54</para>
		/// <para>Name: SelectAll</para>
		/// <para>Input: </para>
		/// <para>Output: List of KhoaBangDiemEntity</para>
		///</summary>
		public List<KhoaBangDiemEntity> SelectAll(){
			IDbCommand cmd=this.CreateSelectAllCommand();
			return this.SelectList(cmd);
		}
		///<summary>
		/// <para>Author: Auto generated by CSharp Code Generator v2.0</para>
		/// <para>Date:16/01/2012 25:11:54</para>
		/// <para>Name: SelectAllDS</para>
		/// <para>Input: </para>
		/// <para>Output: DataSet</para>
		///</summary>
		public DataSet SelectAllDS(){
			IDbCommand cmd=this.CreateSelectAllCommand();
			return this.SelectDS(cmd);
		}
		///<summary>
		/// <para>Author: Auto generated by CSharp Code Generator v2.0</para>
		/// <para>Date:16/01/2012 25:11:54</para>
		/// <para>Name: CreateSelectAllFilterCommand</para>
		/// <para>Input: </para>
		/// <para>Output: IDbCommand</para>
		///</summary>
		protected IDbCommand CreateSelectAllFilterCommand(string strFilter){
			string strSQL="SELECT  [KhoaBangDiem_ID],[LoaiDiem_ID],[MonHoc_ID],[LanThi],[User_ID],[KhoaDoiTuong_ID],[LoaiKhoa],[TrangThai],[NgayKhoa] FROM [KhoaBangDiem]  WHERE "+RemoveInjection(strFilter);
			IDbCommand cmd=this.CreateCommand(strSQL);
			cmd.CommandType=CommandType.Text;
			return cmd;
		}
		///<summary>
		/// <para>Author: Auto generated by CSharp Code Generator v2.0</para>
		/// <para>Date:16/01/2012 25:11:54</para>
		/// <para>Name: CreateSelectAllByKeyFilterCommand</para>
		/// <para>Input: ColumnName,ColumnValue</para>
		/// <para>Output: IDbCommand</para>
		///</summary>
		protected IDbCommand CreateSelectAllByKeyFilterCommand(string strFilter,string ColumnName,object Value){
			string strSQL="SELECT  [KhoaBangDiem_ID],[LoaiDiem_ID],[MonHoc_ID],[LanThi],[User_ID],[KhoaDoiTuong_ID],[LoaiKhoa],[TrangThai],[NgayKhoa] FROM [KhoaBangDiem]  WHERE [KhoaBangDiem].["+ColumnName+"]=@ColumnName AND "+RemoveInjection(strFilter);
			IDbCommand cmd=this.CreateCommand(strSQL);
			cmd.CommandType=CommandType.Text;
			this.CreateCommandParameter(cmd,"@ColumnName",Value);



			return cmd;
		}
		///<summary>
		/// <para>Author: Auto generated by CSharp Code Generator v2.0</para>
		/// <para>Date:16/01/2012 25:11:54</para>
		/// <para>Name: SelectAll</para>
		/// <para>Input: </para>
		/// <para>Output: List of KhoaBangDiemEntity</para>
		///</summary>
		public List<KhoaBangDiemEntity> SelectAllFilter(string strFilter){
			IDbCommand cmd=this.CreateSelectAllFilterCommand(strFilter);
			return this.SelectList(cmd);
		}
		///<summary>
		/// <para>Author: Auto generated by CSharp Code Generator v2.0</para>
		/// <para>Date:16/01/2012 25:11:54</para>
		/// <para>Name: SelectAllDSFilter</para>
		/// <para>Input: </para>
		/// <para>Output: DataSet</para>
		///</summary>
		public DataSet SelectAllDSFilter(string strFilter){
			IDbCommand cmd=this.CreateSelectAllFilterCommand(strFilter);
			return this.SelectDS(cmd);
		}
		#endregion

		#region Insert functions
		///<summary>
		/// <para>Author: Auto generated by CSharp Code Generator v2.0</para>
		/// <para>Date:16/01/2012 25:11:54</para>
		/// <para>Name: CreateInsertCommand</para>
		/// <para>Input: KhoaBangDiemEntity</para>
		/// <para>Output: IDbCommand</para>
		///</summary>
		protected IDbCommand CreateInsertCommand(KhoaBangDiemEntity o){
			string strSQL="INSERT INTO [KhoaBangDiem]([LoaiDiem_ID],[MonHoc_ID],[LanThi],[User_ID],[KhoaDoiTuong_ID],[LoaiKhoa],[TrangThai],[NgayKhoa]) VALUES  (@LoaiDiem_ID,@MonHoc_ID,@LanThi,@User_ID,@KhoaDoiTuong_ID,@LoaiKhoa,@TrangThai,@NgayKhoa);SELECT  @@IDENTITY";
			IDbCommand cmd=this.CreateCommand(strSQL);
			cmd.CommandType=CommandType.Text;
			if(o.IsNullLoaiDiem_ID)
				this.CreateCommandParameter(cmd,"@LoaiDiem_ID",System.DBNull.Value);
			else
				this.CreateCommandParameter(cmd,"@LoaiDiem_ID",o.LoaiDiem_ID);

			if(o.IsNullMonHoc_ID)
				this.CreateCommandParameter(cmd,"@MonHoc_ID",System.DBNull.Value);
			else
				this.CreateCommandParameter(cmd,"@MonHoc_ID",o.MonHoc_ID);

			if(o.IsNullLanThi)
				this.CreateCommandParameter(cmd,"@LanThi",System.DBNull.Value);
			else
				this.CreateCommandParameter(cmd,"@LanThi",o.LanThi);

			if(o.IsNullUser_ID)
				this.CreateCommandParameter(cmd,"@User_ID",System.DBNull.Value);
			else
				this.CreateCommandParameter(cmd,"@User_ID",o.User_ID);

			if(o.IsNullKhoaDoiTuong_ID)
				this.CreateCommandParameter(cmd,"@KhoaDoiTuong_ID",System.DBNull.Value);
			else
				this.CreateCommandParameter(cmd,"@KhoaDoiTuong_ID",o.KhoaDoiTuong_ID);

			if(o.IsNullLoaiKhoa)
				this.CreateCommandParameter(cmd,"@LoaiKhoa",System.DBNull.Value);
			else
				this.CreateCommandParameter(cmd,"@LoaiKhoa",o.LoaiKhoa);

			if(o.IsNullTrangThai)
				this.CreateCommandParameter(cmd,"@TrangThai",System.DBNull.Value);
			else
				this.CreateCommandParameter(cmd,"@TrangThai",o.TrangThai);

			if(o.IsNullNgayKhoa)
				this.CreateCommandParameter(cmd,"@NgayKhoa",System.DBNull.Value);
			else
				this.CreateCommandParameter(cmd,"@NgayKhoa",o.NgayKhoa);


			return cmd;
		}
		///<summary>
		/// <para>Author: Auto generated by CSharp Code Generator v2.0</para>
		/// <para>Date:16/01/2012 25:11:54</para>
		/// <para>Name: Save</para>
		/// <para>Input: KhoaBangDiemEntity</para>
		/// <para>Output: return true if succeeded else return false</para>
		///</summary>
		public bool Save(KhoaBangDiemEntity o){
			bool result=false;
			IDbCommand cmd=this.CreateInsertCommand(o);
			object id=this.ExecuteScalar(cmd,ref result);
			cmd.Dispose();
			try{
				o.KhoaBangDiem_ID=int.Parse(Convert.ToString(id));
			}
			catch{}
			return result;
		}
		///<summary>
		/// <para>Author: Auto generated by CSharp Code Generator v2.0</para>
		/// <para>Date:16/01/2012 25:11:54</para>
		/// <para>Name: SaveList</para>
		/// <para>Input: List of KhoaBangDiemEntity</para>
		/// <para>Output: </para>
		///</summary>
		public void SaveList(List<KhoaBangDiemEntity>list){
			foreach(KhoaBangDiemEntity o in list){
				try{
					this.Save(o);
				}
				catch{
				}
			}
		}
		#endregion

		#region Update functions
		///<summary>
		/// <para>Author: Auto generated by CSharp Code Generator v2.0</para>
		/// <para>Date:16/01/2012 25:11:54</para>
		/// <para>Name: CreateUpdateCommand</para>
		/// <para>Input: KhoaBangDiemEntity</para>
		/// <para>Output: </para>
		///</summary>
		protected IDbCommand CreateUpdateCommand(KhoaBangDiemEntity o){
			string strSQL="UPDATE  [KhoaBangDiem] SET [KhoaBangDiem].[LoaiDiem_ID]=@LoaiDiem_ID,[KhoaBangDiem].[MonHoc_ID]=@MonHoc_ID,[KhoaBangDiem].[LanThi]=@LanThi,[KhoaBangDiem].[User_ID]=@User_ID,[KhoaBangDiem].[KhoaDoiTuong_ID]=@KhoaDoiTuong_ID,[KhoaBangDiem].[LoaiKhoa]=@LoaiKhoa,[KhoaBangDiem].[TrangThai]=@TrangThai,[KhoaBangDiem].[NgayKhoa]=@NgayKhoa WHERE [KhoaBangDiem].[KhoaBangDiem_ID]=@KhoaBangDiem_ID";
			IDbCommand cmd=this.CreateCommand(strSQL);
			cmd.CommandType=CommandType.Text;
			if(o.IsNullKhoaBangDiem_ID)
				this.CreateCommandParameter(cmd,"@KhoaBangDiem_ID",System.DBNull.Value);
			else
				this.CreateCommandParameter(cmd,"@KhoaBangDiem_ID",o.KhoaBangDiem_ID);

			if(o.IsNullLoaiDiem_ID)
				this.CreateCommandParameter(cmd,"@LoaiDiem_ID",System.DBNull.Value);
			else
				this.CreateCommandParameter(cmd,"@LoaiDiem_ID",o.LoaiDiem_ID);

			if(o.IsNullMonHoc_ID)
				this.CreateCommandParameter(cmd,"@MonHoc_ID",System.DBNull.Value);
			else
				this.CreateCommandParameter(cmd,"@MonHoc_ID",o.MonHoc_ID);

			if(o.IsNullLanThi)
				this.CreateCommandParameter(cmd,"@LanThi",System.DBNull.Value);
			else
				this.CreateCommandParameter(cmd,"@LanThi",o.LanThi);

			if(o.IsNullUser_ID)
				this.CreateCommandParameter(cmd,"@User_ID",System.DBNull.Value);
			else
				this.CreateCommandParameter(cmd,"@User_ID",o.User_ID);

			if(o.IsNullKhoaDoiTuong_ID)
				this.CreateCommandParameter(cmd,"@KhoaDoiTuong_ID",System.DBNull.Value);
			else
				this.CreateCommandParameter(cmd,"@KhoaDoiTuong_ID",o.KhoaDoiTuong_ID);

			if(o.IsNullLoaiKhoa)
				this.CreateCommandParameter(cmd,"@LoaiKhoa",System.DBNull.Value);
			else
				this.CreateCommandParameter(cmd,"@LoaiKhoa",o.LoaiKhoa);

			if(o.IsNullTrangThai)
				this.CreateCommandParameter(cmd,"@TrangThai",System.DBNull.Value);
			else
				this.CreateCommandParameter(cmd,"@TrangThai",o.TrangThai);

			if(o.IsNullNgayKhoa)
				this.CreateCommandParameter(cmd,"@NgayKhoa",System.DBNull.Value);
			else
				this.CreateCommandParameter(cmd,"@NgayKhoa",o.NgayKhoa);


			return cmd;
		}
		///<summary>
		/// <para>Author: Auto generated by CSharp Code Generator v2.0</para>
		/// <para>Date:16/01/2012 25:11:54</para>
		/// <para>Name: CreateUpdateFieldCommand</para>
		/// <para>Input: ColumnName,ColumnValue,KhoaBangDiem_ID</para>
		/// <para>Output: IDbCommand</para>
		///</summary>
		protected IDbCommand CreateUpdateFieldCommand(string ColumnName,object Value,int KhoaBangDiem_ID){
			string strSQL="UPDATE  [KhoaBangDiem] SET [KhoaBangDiem].["+ColumnName+"]=@ColumnName WHERE [KhoaBangDiem].[KhoaBangDiem_ID]=@KhoaBangDiem_ID";
			IDbCommand cmd=this.CreateCommand(strSQL);
			cmd.CommandType=CommandType.Text;
			this.CreateCommandParameter(cmd,"@KhoaBangDiem_ID",KhoaBangDiem_ID);



			this.CreateCommandParameter(cmd,"@ColumnName",Value);


			return cmd;
		}
		///<summary>
		/// <para>Author: Auto generated by CSharp Code Generator v2.0</para>
		/// <para>Date:16/01/2012 25:11:54</para>
		/// <para>Name: Update</para>
		/// <para>Input: KhoaBangDiemEntity</para>
		/// <para>Output: return true if succeeded else return false</para>
		///</summary>
		public bool Update(KhoaBangDiemEntity o){
			IDbCommand cmd=this.CreateUpdateCommand(o);
			bool result=this.ExcuteNoneQuery(cmd);
			cmd.Dispose();
			return result;
		}
		///<summary>
		/// <para>Author: Auto generated by CSharp Code Generator v2.0</para>
		/// <para>Date:16/01/2012 25:11:54</para>
		/// <para>Name: UpdateList</para>
		/// <para>Input: List of KhoaBangDiemEntity</para>
		/// <para>Output: </para>
		///</summary>
		public void UpdateList(List<KhoaBangDiemEntity>list){
			foreach(KhoaBangDiemEntity o in list){
				try{
					this.Update(o);
				}
				catch{
				}
			}
		}
		///<summary>
		/// <para>Author: Auto generated by CSharp Code Generator v2.0</para>
		/// <para>Date:16/01/2012 25:11:54</para>
		/// <para>Name: UpdateLoaiDiem_ID</para>
		/// <para>Input: NewLoaiDiem_ID,KhoaBangDiem_ID</para>
		/// <para>Output: return true if succeeded else return false</para>
		///</summary>
		public bool UpdateLoaiDiem_ID(int NewLoaiDiem_ID,int KhoaBangDiem_ID){
			IDbCommand cmd=this.CreateUpdateFieldCommand("LoaiDiem_ID",NewLoaiDiem_ID,KhoaBangDiem_ID);
			bool result=this.ExcuteNoneQuery(cmd);
			cmd.Dispose();
			return result;
		}
		///<summary>
		/// <para>Author: Auto generated by CSharp Code Generator v2.0</para>
		/// <para>Date:16/01/2012 25:11:54</para>
		/// <para>Name: UpdateMonHoc_ID</para>
		/// <para>Input: NewMonHoc_ID,KhoaBangDiem_ID</para>
		/// <para>Output: return true if succeeded else return false</para>
		///</summary>
		public bool UpdateMonHoc_ID(int NewMonHoc_ID,int KhoaBangDiem_ID){
			IDbCommand cmd=this.CreateUpdateFieldCommand("MonHoc_ID",NewMonHoc_ID,KhoaBangDiem_ID);
			bool result=this.ExcuteNoneQuery(cmd);
			cmd.Dispose();
			return result;
		}
		///<summary>
		/// <para>Author: Auto generated by CSharp Code Generator v2.0</para>
		/// <para>Date:16/01/2012 25:11:54</para>
		/// <para>Name: UpdateLanThi</para>
		/// <para>Input: NewLanThi,KhoaBangDiem_ID</para>
		/// <para>Output: return true if succeeded else return false</para>
		///</summary>
		public bool UpdateLanThi(int NewLanThi,int KhoaBangDiem_ID){
			IDbCommand cmd=this.CreateUpdateFieldCommand("LanThi",NewLanThi,KhoaBangDiem_ID);
			bool result=this.ExcuteNoneQuery(cmd);
			cmd.Dispose();
			return result;
		}
		///<summary>
		/// <para>Author: Auto generated by CSharp Code Generator v2.0</para>
		/// <para>Date:16/01/2012 25:11:54</para>
		/// <para>Name: UpdateUser_ID</para>
		/// <para>Input: NewUser_ID,KhoaBangDiem_ID</para>
		/// <para>Output: return true if succeeded else return false</para>
		///</summary>
		public bool UpdateUser_ID(int NewUser_ID,int KhoaBangDiem_ID){
			IDbCommand cmd=this.CreateUpdateFieldCommand("User_ID",NewUser_ID,KhoaBangDiem_ID);
			bool result=this.ExcuteNoneQuery(cmd);
			cmd.Dispose();
			return result;
		}
		///<summary>
		/// <para>Author: Auto generated by CSharp Code Generator v2.0</para>
		/// <para>Date:16/01/2012 25:11:54</para>
		/// <para>Name: UpdateKhoaDoiTuong_ID</para>
		/// <para>Input: NewKhoaDoiTuong_ID,KhoaBangDiem_ID</para>
		/// <para>Output: return true if succeeded else return false</para>
		///</summary>
		public bool UpdateKhoaDoiTuong_ID(int NewKhoaDoiTuong_ID,int KhoaBangDiem_ID){
			IDbCommand cmd=this.CreateUpdateFieldCommand("KhoaDoiTuong_ID",NewKhoaDoiTuong_ID,KhoaBangDiem_ID);
			bool result=this.ExcuteNoneQuery(cmd);
			cmd.Dispose();
			return result;
		}
		///<summary>
		/// <para>Author: Auto generated by CSharp Code Generator v2.0</para>
		/// <para>Date:16/01/2012 25:11:54</para>
		/// <para>Name: UpdateLoaiKhoa</para>
		/// <para>Input: NewLoaiKhoa,KhoaBangDiem_ID</para>
		/// <para>Output: return true if succeeded else return false</para>
		///</summary>
		public bool UpdateLoaiKhoa(Byte NewLoaiKhoa,int KhoaBangDiem_ID){
			IDbCommand cmd=this.CreateUpdateFieldCommand("LoaiKhoa",NewLoaiKhoa,KhoaBangDiem_ID);
			bool result=this.ExcuteNoneQuery(cmd);
			cmd.Dispose();
			return result;
		}
		///<summary>
		/// <para>Author: Auto generated by CSharp Code Generator v2.0</para>
		/// <para>Date:16/01/2012 25:11:54</para>
		/// <para>Name: UpdateTrangThai</para>
		/// <para>Input: NewTrangThai,KhoaBangDiem_ID</para>
		/// <para>Output: return true if succeeded else return false</para>
		///</summary>
		public bool UpdateTrangThai(Byte NewTrangThai,int KhoaBangDiem_ID){
			IDbCommand cmd=this.CreateUpdateFieldCommand("TrangThai",NewTrangThai,KhoaBangDiem_ID);
			bool result=this.ExcuteNoneQuery(cmd);
			cmd.Dispose();
			return result;
		}
		///<summary>
		/// <para>Author: Auto generated by CSharp Code Generator v2.0</para>
		/// <para>Date:16/01/2012 25:11:54</para>
		/// <para>Name: UpdateNgayKhoa</para>
		/// <para>Input: NewNgayKhoa,KhoaBangDiem_ID</para>
		/// <para>Output: return true if succeeded else return false</para>
		///</summary>
		public bool UpdateNgayKhoa(DateTime NewNgayKhoa,int KhoaBangDiem_ID){
			IDbCommand cmd=this.CreateUpdateFieldCommand("NgayKhoa",NewNgayKhoa,KhoaBangDiem_ID);
			bool result=this.ExcuteNoneQuery(cmd);
			cmd.Dispose();
			return result;
		}
		#endregion

		#region Delete functions
		///<summary>
		/// <para>Author: Auto generated by CSharp Code Generator v2.0</para>
		/// <para>Date:16/01/2012 25:11:54</para>
		/// <para>Name: DeleteAllCommand</para>
		/// <para>Input: </para>
		/// <para>Output: IDbCommand</para>
		///</summary>
		protected IDbCommand CreateDeleteAllCommand(){
			string strSQL="DELETE   FROM [KhoaBangDiem]  ";
			IDbCommand cmd=this.CreateCommand(strSQL);
			cmd.CommandType=CommandType.Text;
			return cmd;
		}
		///<summary>
		/// <para>Author: Auto generated by CSharp Code Generator v2.0</para>
		/// <para>Date:16/01/2012 25:11:54</para>
		/// <para>Name: DeleteCommand</para>
		/// <para>Input: KhoaBangDiemEntity</para>
		/// <para>Output: IDbCommand</para>
		///</summary>
		protected IDbCommand CreateDeleteCommand(KhoaBangDiemEntity o){
			string strSQL="DELETE   FROM [KhoaBangDiem]   WHERE [KhoaBangDiem].[KhoaBangDiem_ID]=@KhoaBangDiem_ID";
			IDbCommand cmd=this.CreateCommand(strSQL);
			cmd.CommandType=CommandType.Text;
			if(o.IsNullKhoaBangDiem_ID)
				this.CreateCommandParameter(cmd,"@KhoaBangDiem_ID",System.DBNull.Value);
			else
				this.CreateCommandParameter(cmd,"@KhoaBangDiem_ID",o.KhoaBangDiem_ID);


			return cmd;
		}
		///<summary>
		/// <para>Author: Auto generated by CSharp Code Generator v2.0</para>
		/// <para>Date:16/01/2012 25:11:54</para>
		/// <para>Name: DeleteAll</para>
		/// <para>Input: </para>
		/// <para>Output: return true if succeeded else return false</para>
		///</summary>
		public bool DeleteAll(){
			IDbCommand cmd=this.CreateDeleteAllCommand();
			bool result=this.ExcuteNoneQuery(cmd);
			cmd.Dispose();
			return result;
		}
		///<summary>
		/// <para>Author: Auto generated by CSharp Code Generator v2.0</para>
		/// <para>Date:16/01/2012 25:11:54</para>
		/// <para>Name: CreateDeleteByPrimaryKeyCommand</para>
		/// <para>Input: KhoaBangDiem_ID</para>
		/// <para>Output: IDbCommand</para>
		///</summary>
		protected IDbCommand CreateDeleteByPrimaryKeyCommand(int KhoaBangDiem_ID){
			string strSQL="DELETE   FROM [KhoaBangDiem]   WHERE [KhoaBangDiem].[KhoaBangDiem_ID]=@KhoaBangDiem_ID";
			IDbCommand cmd=this.CreateCommand(strSQL);
			cmd.CommandType=CommandType.Text;
			this.CreateCommandParameter(cmd,"@KhoaBangDiem_ID",KhoaBangDiem_ID);



			return cmd;
		}
		///<summary>
		/// <para>Author: Auto generated by CSharp Code Generator v2.0</para>
		/// <para>Date:16/01/2012 25:11:54</para>
		/// <para>Name: CreateDeleteByKeyCommand</para>
		/// <para>Input: ColumnName , ColumnValue</para>
		/// <para>Output: IDbCommand</para>
		///</summary>
		protected IDbCommand CreateDeleteByKeyCommand(string ColumnName,object Value){
			string strSQL="DELETE   FROM [KhoaBangDiem]   WHERE [KhoaBangDiem].["+ColumnName+"]=@ColumnName";
			IDbCommand cmd=this.CreateCommand(strSQL);
			cmd.CommandType=CommandType.Text;
			this.CreateCommandParameter(cmd,"@ColumnName",Value);



			return cmd;
		}
		///<summary>
		/// <para>Author: Auto generated by CSharp Code Generator v2.0</para>
		/// <para>Date:16/01/2012 25:11:54</para>
		/// <para>Name: Delete</para>
		/// <para>Input: KhoaBangDiemEntity</para>
		/// <para>Output: return true if succeeded else return false</para>
		///</summary>
		public bool Delete(KhoaBangDiemEntity o){
			IDbCommand cmd=this.CreateDeleteCommand(o);
			bool result=this.ExcuteNoneQuery(cmd);
			cmd.Dispose();
			return result;
		}
		///<summary>
		/// <para>Author: Auto generated by CSharp Code Generator v2.0</para>
		/// <para>Date:16/01/2012 25:11:54</para>
		/// <para>Name: DeleteByID</para>
		/// <para>Input: KhoaBangDiem_ID</para>
		/// <para>Output: return true if succeeded else return false</para>
		///</summary>
		public bool DeleteByID(int KhoaBangDiem_ID){
			IDbCommand cmd=this.CreateDeleteByPrimaryKeyCommand(KhoaBangDiem_ID);
			bool result=this.ExcuteNoneQuery(cmd);
			cmd.Dispose();
			return result;
		}
		#endregion

		#region Select,delete by KhoaBangDiem_ID functions
		#endregion

		#region MapObject functions
		///<summary>
		/// <para>Author: Auto generated by CSharp Code Generator v2.0</para>
		/// <para>Date:16/01/2012 25:11:54</para>
		/// <para>Name: MapObject</para>
		/// <para>Input: IDataReader</para>
		/// <para>Output: KhoaBangDiemEntity</para>
		///</summary>
		protected override KhoaBangDiemEntity MapObject(IDataReader r){
			KhoaBangDiemEntity entity = new KhoaBangDiemEntity();
			try{
				if(r.FieldCount>0){
					try
					{
						int ordinal = r.GetOrdinal("KhoaBangDiem_ID");
						if (!r.IsDBNull(ordinal)) entity.KhoaBangDiem_ID = ((int)(r.GetValue(ordinal)));
					}
					catch{}
					try
					{
						int ordinal = r.GetOrdinal("LoaiDiem_ID");
						if (!r.IsDBNull(ordinal)) entity.LoaiDiem_ID = ((int)(r.GetValue(ordinal)));
					}
					catch{}
					try
					{
						int ordinal = r.GetOrdinal("MonHoc_ID");
						if (!r.IsDBNull(ordinal)) entity.MonHoc_ID = ((int)(r.GetValue(ordinal)));
					}
					catch{}
					try
					{
						int ordinal = r.GetOrdinal("LanThi");
						if (!r.IsDBNull(ordinal)) entity.LanThi = ((int)(r.GetValue(ordinal)));
					}
					catch{}
					try
					{
						int ordinal = r.GetOrdinal("User_ID");
						if (!r.IsDBNull(ordinal)) entity.User_ID = ((int)(r.GetValue(ordinal)));
					}
					catch{}
					try
					{
						int ordinal = r.GetOrdinal("KhoaDoiTuong_ID");
						if (!r.IsDBNull(ordinal)) entity.KhoaDoiTuong_ID = ((int)(r.GetValue(ordinal)));
					}
					catch{}
					try
					{
						int ordinal = r.GetOrdinal("LoaiKhoa");
						if (!r.IsDBNull(ordinal)) entity.LoaiKhoa = ((Byte)(r.GetValue(ordinal)));
					}
					catch{}
					try
					{
						int ordinal = r.GetOrdinal("TrangThai");
						if (!r.IsDBNull(ordinal)) entity.TrangThai = ((Byte)(r.GetValue(ordinal)));
					}
					catch{}
					try
					{
						int ordinal = r.GetOrdinal("NgayKhoa");
						if (!r.IsDBNull(ordinal)) entity.NgayKhoa = ((DateTime)(r.GetValue(ordinal)));
					}
					catch{}
					return entity;
				}
			}catch{}
			return null;
		}
		#endregion
	}
	/*****************************************************************************************************/
	/**********************************END KhoaBangDiemDAOBase*****************************************/
	/*****************************************************************************************************/
}

